package com.yunhe.common.client;

import com.yunhe.common.client.fallback.WebAuthorityFallbackFactory;
import com.yunhe.common.exception.ObjectNotFoundException;
import com.yunhe.common.model.ResultObject;
import com.yunhe.common.model.authority.*;
import com.yunhe.common.model.company.Company;
import com.yunhe.common.model.company.Employee;
import com.yunhe.common.model.office.Office;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 权限Feign客户端
 * 避免出现相同value的Feign，在value中添加“http://”
 * @author liuronglei
 */
@FeignClient(value = "http://yh-authority", fallbackFactory = WebAuthorityFallbackFactory.class)
public interface WebAuthorityClient {

    /**
     * 根据ID获得用户对象
     *
     * @param id 用户ID
     */
    @RequestMapping(value = "/users/{id}", method = RequestMethod.GET)
    ResponseEntity<ResultObject<User>> getUserById(@RequestParam("id") Long id);

    /**
     * 根据ID获得电站对象
     * @param stationId 电站ID
     */
    @RequestMapping(value = "/stations/{stationId}", method = RequestMethod.GET)
    ResponseEntity<ResultObject<Station>> getStationById(@RequestParam("stationId") Long stationId);

    /**
     * 根据ID获得单位对象
     * @param firmId 单位ID
     */
    @RequestMapping(value = "/firms/{firmId}", method = RequestMethod.GET)
    ResponseEntity<ResultObject<Firm>> getFirmById(@RequestParam("firmId") Long firmId);

    /**
     * 根据组织id获取组织对象
     * @param orgId
     * @return
     */
    @RequestMapping(value = "/organization/searchById/{id}", method = RequestMethod.GET)
    ResponseEntity<ResultObject<Organization>> getOrgById(@PathVariable(value = "id") Long orgId);
    /**
     * 根据厂房id查询厂房信息
     * @param officeId
     * @return
     */
    @RequestMapping(value = "/office/getOfficeById", method = RequestMethod.GET)
    ResponseEntity<ResultObject<Office>> getOfficeById(@RequestParam("id") Long officeId);

    @RequestMapping(value = "/realStation/findById/{id}", method = RequestMethod.GET)
    ResponseEntity<ResultObject<RealStation>> getRealStationById(@PathVariable("id")Long fieldValueLong);

    @RequestMapping(value = "/companys/{id}", method = RequestMethod.GET)
    ResponseEntity<ResultObject<Company>> getCompanyById(@PathVariable("id") Long fieldValueLong) throws ObjectNotFoundException;

    @RequestMapping(value = "/employees/{id}", method = RequestMethod.GET)
    ResponseEntity<ResultObject<Employee>> getEmployeeById(@PathVariable("id") Long fieldValueLong) ;
}